#pragma once

inline
	PIMAGE_FILE_HEADER GetFileHeaderFromBase(char* BaseAddress)
{
	return (PIMAGE_FILE_HEADER)(BaseAddress + *(ULONG*)(BaseAddress + 0x3C) + 4);
}
inline
	PIMAGE_OPTIONAL_HEADER GetOptionalHeaderFromBase(char* BaseAddress)
{
	PIMAGE_FILE_HEADER pFileHeader = GetFileHeaderFromBase(BaseAddress);
	return (PIMAGE_OPTIONAL_HEADER)(pFileHeader + 1);
}
inline
	PIMAGE_SECTION_HEADER GetSectionHeaderFromFileHeader(PIMAGE_FILE_HEADER pFileHeader)
{
	return (PIMAGE_SECTION_HEADER)((char*)(pFileHeader + 1) + pFileHeader->SizeOfOptionalHeader);
}


typedef BOOL (*PEnumImportModule)(
	PIMAGE_IMPORT_DESCRIPTOR pImportDescriptor,
	char* pRealImageBase,
	ULONG SizeOfImage,
	ULONG_PTR Parameter
	);

BOOL ValidatePeFile(char* pPeFile, ULONG FileSize);
BOOL LayoutPe(char*pPeFile, ULONG FileSize, char* pRealImageBase, ULONG SizeOfImage);
BOOL EnumImportModules(
	__in char* pRealImageBase, 
	__in PEnumImportModule EnumImportModule, 
	__in ULONG_PTR Parameter
	);
BOOL ProcessRelocations(
	char* pRealImageBase,
	ULONG_PTR BaseDiff
	);